<template>
  <div class="w-100 h-100 rfsssl">
    <div
      v-if="list"
      class="item"
      v-for="(item, index) in list"
      :key="item.label"
      :class="'bg' + index"
      :style="{}"
    >
      <div class="itemLabel">{{ item.label }}</div>
      <div class="child" v-for="child in item.children" :key="item.label">
        <span class="label" v-if="child.label">{{ child.label }}</span>
        <span class="value" :style="{ color: item.color }">
          {{ child.value }}
        </span>
        <span>个</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import bg1 from "@/assets/image/underGround/dsx1.png";
import bg2 from "@/assets/image/underGround/dsx2.png";
import bg3 from "@/assets/image/underGround/dsx3.png";

const baseList = [
  {
    label: "防护设施数量",
    color: "#00F3FF",
    children: [
      {
        label: "防护门",
      },
      {
        label: "防护密闭门",
      },
      {
        label: "防爆波活门",
      },
    ],
  },
  {
    label: "消防设施数量",
    color: "#00FFB1",
    children: [{ label: "消防栓" }, { label: "灭火器" }],
  },
  {
    label: "人护指挥数量",
    color: "#FFE6BE",
    children: [{ label: "" }],
  },
];

const jsonData: any = inject("jsonData");
const current = computed(() => {
  let data = [];
  try {
    data = jsonData.value.underJsc.rfsssl;
  } catch (error) {}

  return data;
});

const list = ref();

watch(
  () => current.value,
  (val) => {
    if (val) {
      try {
        const arr = baseList.map((item, index) => {
          item.children = item.children.map((child, i) => {
            return {
              ...child,
              value: val[index][i],
            };
          });

          return item;
        });
        list.value = arr;
      } catch (error) {}
    }
  }
);
</script>

<style lang="less" scoped>
.rfsssl {
  padding: 20px 20px 0;
}
.item {
  height: 55px;
  display: flex;
  align-items: center;
  padding-left: 120px;
  & ~ .item {
    margin-top: 36px;
  }
}
.itemLabel {
  margin-right: 60px;
}
.child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  .label {
    margin-right: 28px;
  }

  .value {
    font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
    font-weight: bold;
  }
  & ~ .child{
    &::before{
        content: '';
        width: 1px;
        height: 100%;
        position: absolute;
        left: 0;
        top: 0;
        background: linear-gradient( 180deg, rgba(0,243,255,0) 0%, #00F3FF 47%, rgba(0,243,255,0) 100%);
    }
  }
}
.bg0 {
  background: url("@/assets/image/underGround/rfsb_1.png") no-repeat center center;
  background-size: 100% 100%;
}
.bg1 {
  background: url("@/assets/image/underGround/rfsb_2.png") no-repeat center center;
  background-size: 100% 100%;
}
.bg2 {
  background: url("@/assets/image/underGround/rfsb_3.png") no-repeat center center;
  background-size: 100% 100%;
}
</style>
